package com.example.user.player;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.content.Intent;




public class MainActivity extends AppCompatActivity {
    private static final int REQUEST_CODE = 0; // 请求码
    // 所需的全部权限
    static final String[] PERMISSIONS = new String[]{
            android.Manifest.permission.READ_EXTERNAL_STORAGE,
            android.Manifest.permission.ACCESS_FINE_LOCATION,
            android.Manifest.permission.CALL_PHONE,
            android.Manifest.permission.CAMERA,
            android.Manifest.permission.SEND_SMS,
            android.Manifest.permission.GET_ACCOUNTS,
            android.Manifest.permission.RECORD_AUDIO,
    };
    private PermissionsChecker mPermissionsChecker;
    private Button button0;
    private Button button1;
    private Button button2;
    private Button button3;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        mPermissionsChecker = new PermissionsChecker(this);
        ashdjkslajfhjawhuiahbcxjhbujkhgblhaskljdkhknasl;;
        if (mPermissionsChecker.lacksPermissions(PERMISSIONS)) {
            PermissionsActivity.startActivityForResult(this, REQUEST_CODE, PERMISSIONS);
        }
        button0=(Button)findViewById(R.id.button0);

        button2=(Button)findViewById(R.id.button2);
        button3=(Button)findViewById(R.id.button3);
        button0.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    Intent intent0=new Intent(MainActivity.this,registerActivity.class);

                    startActivity(intent0);
                }
        });

        button2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2=new Intent(MainActivity.this,MusicActivity.class);
                startActivity(intent2);
            }
        });
        button3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent3=new Intent(MainActivity.this,AudioActivity.class);
                startActivity(intent3);
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // 拒绝时, 关闭页面, 缺少主要权限, 无法运行
        if (requestCode == REQUEST_CODE && resultCode == PermissionsActivity.PERMISSIONS_DENIED) {
//            finish();
//            Helper.showToast("拒绝权限将导致部分功能无法使用");
        }
    }
}

